package com.geticsen.leetcode;

import java.util.ArrayList;
import java.util.List;

//https://leetcode-cn.com/problems/pascals-triangle-ii/
public class Solution_119 {
    public List<Integer> getRow(int rowIndex) {
        List<List<Integer>> res = new ArrayList<>();

        for (int i = 0; i <= rowIndex; i++) {
            List<Integer> temp = new ArrayList<>();
            temp.add(1);
            for (int j = 2; j <= i; j++) {
                temp.add(res.get(i - 1).get(j - 1) + res.get(i - 1).get(j - 2));
            }
            if (i > 0) {
                temp.add(1);
            }
            res.add(temp);
        }
        return res.get(rowIndex);
    }
}
